package com.gosling.cloudspace.config.mybatis;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.github.yulichang.interceptor.MPJInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * MP配置类
 *
 * @author lihonglin
 * @date 2022/5/9 10:36
 */
@Configuration
public class MybatisPlusConfig {

    /**
     * 启用连表拦截器
     */
    @Bean
    public MybatisPlusInterceptor paginationInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //分页插件
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
        //连表插件
        interceptor.addInnerInterceptor(new MPJInterceptor());
        //多租户,垃圾sql拦截插件......
        return interceptor;
    }

}